/*
 * Copyright (C) 2009 Ionut Dediu <deionut@yahoo.com>
 *
 * Licensed under the GNU General Public License Version 2
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

// SmartCamSettingsContainer.cpp

#include <SmartCam_0xE696FBC9.rsg>

#include "SmartCamSettingsContainer.h"
#include "SmartCamSettingsList.h"

CSmartCamSettingsContainer::CSmartCamSettingsContainer():
	iSettingsList(NULL)
    {
    }

CSmartCamSettingsContainer* CSmartCamSettingsContainer::NewL(
		CSmartCamSettingsData& aSettingsData)
    {
    CSmartCamSettingsContainer* self = CSmartCamSettingsContainer::NewLC(aSettingsData);
    CleanupStack::Pop(self);
    return self;
    }

CSmartCamSettingsContainer* CSmartCamSettingsContainer::NewLC(
		CSmartCamSettingsData& aSettingsData)
    {
    CSmartCamSettingsContainer* self = new (ELeave) CSmartCamSettingsContainer();
    CleanupStack::PushL(self);
    self->ConstructL(aSettingsData);
    return self;
    }

void CSmartCamSettingsContainer::ConstructL(CSmartCamSettingsData& aSettingsData)
    {
    iSettingsList = CSmartCamSettingsList::NewL(aSettingsData);
    iSettingsList->SetContainerWindowL(*this);
    iSettingsList->ConstructFromResourceL(R_SMARTCAM_SETTINGS_LIST);
    }

CSmartCamSettingsContainer::~CSmartCamSettingsContainer()
    {
    delete iSettingsList;
    iSettingsList = NULL;
    }

TInt CSmartCamSettingsContainer::CountComponentControls() const
    {
    return 1;
    }

CCoeControl* CSmartCamSettingsContainer::ComponentControl(TInt /* aIndex */ ) const
    {
    return iSettingsList;
    }

TKeyResponse CSmartCamSettingsContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
    {
    if(aKeyEvent.iCode == EKeyLeftArrow ||
       aKeyEvent.iCode == EKeyRightArrow )
    	{
        // Listbox takes all events even if it doesn't use them
        return EKeyWasNotConsumed;
	    }
    return iSettingsList->OfferKeyEventL(aKeyEvent, aType);
    }

void CSmartCamSettingsContainer::SizeChanged()
    {
    if(iSettingsList)
	    {
        iSettingsList->SetRect(Rect());
	    }
    }

